import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.npc_woman = pygame.image.load("../资源/图片/老太.png").convert_alpha()
        self.hammer = pygame.image.load("../资源/图片/榔头.png").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.gold_guard = pygame.image.load("../资源/图片/金卫士.png").convert_alpha()
        self.gold_leader = pygame.image.load("../资源/图片/金队长.png").convert_alpha()
        self.dark_guard = pygame.image.load("../资源/图片/冥卫兵.png").convert_alpha()
        self.dark_soldier = pygame.image.load("../资源/图片/冥战士.png").convert_alpha()
        self.ling_warrior = pygame.image.load("../资源/图片/灵武士.png").convert_alpha()
        self.ling_master = pygame.image.load("../资源/图片/灵法师.png").convert_alpha()
        self.senior_guard = pygame.image.load("../资源/图片/高级卫兵.png").convert_alpha()
        self.double_sword = pygame.image.load("../资源/图片/双手剑士.png").convert_alpha()

        self.hero_pos = (9, 10)
        self.up_pos = (0, 10)
        self.down_pos = (10, 10)
        self.variable_pos = {
            (0, 0): (self.npc_woman, '12楼老太'),
            (10, 0): (self.hammer, '榔头'),
            (5, 1): (self.door_yellow, '黄门'),
            (2, 8): (self.door_yellow, '黄门'),
            (8, 8): (self.door_yellow, '黄门'),
            (1, 5): (self.door_blue, '蓝门'),
            (9, 5): (self.door_blue, '蓝门'),
            (5, 9): (self.door_blue, '蓝门'),
            (5, 3): (self.key_yellow, '黄钥匙'),
            (5, 4): (self.key_yellow, '黄钥匙'),
            (5, 5): (self.hp_blue, '红药'),
            (5, 6): (self.hp_blue, '红药'),
            (9, 0): (self.hp_blue, '蓝药'),
            (10, 1): (self.hp_blue, '蓝药'),
            (1, 0): (self.gem_blue, '蓝宝石'),
            (0, 8): (self.gem_blue, '蓝宝石'),
            (0, 1): (self.gem_red, '红宝石'),
            (10, 8): (self.gem_red, '红宝石'),
            (4, 0): (self.gold_guard, '金卫士'),
            (6, 0): (self.gold_guard, '金卫士'),
            (5, 0): (self.gold_leader, '金队长'),
            (5, 2): (self.gold_leader, '金队长'),
            (3, 8): (self.dark_guard, '冥卫兵'),
            (4, 8): (self.dark_guard, '冥卫兵'),
            (6, 8): (self.dark_guard, '冥卫兵'),
            (7, 8): (self.dark_guard, '冥卫兵'),
            (1, 4): (self.dark_soldier, '冥战士'),
            (9, 3): (self.ling_warrior, '灵武士'),
            (10, 4): (self.ling_warrior, '灵武士'),
            (9, 4): (self.ling_master, '灵法师'),
            (5, 8): (self.senior_guard, '高级卫兵'),
            (0, 4): (self.double_sword, '双手剑士'),
            (1, 3): (self.double_sword, '双手剑士'),
            (1, 8): (self.double_sword, '双手剑士'),
            (9, 8): (self.double_sword, '双手剑士'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(11):
            if i != 5:
                self.draw(self.wall, i, 9)
                self.dic[(i, 9)] = '墙'
            if i != 3 and i != 7:
                self.draw(self.wall, i, 7)
                self.dic[(i, 7)] = '墙'
        for i in range(6):
            self.draw(self.wall, 2, i)
            self.dic[(2, i)] = '墙'
            self.draw(self.wall, 8, i)
            self.dic[(8, i)] = '墙'
            if i != 0:
                self.draw(self.wall, 4, i)
                self.dic[(4, i+1)] = '墙'
                self.draw(self.wall, 6, i)
                self.dic[(6, i+1)] = '墙'
        for i in [(0, 5), (10, 5), (4, 6), (6, 6)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
